From: Julien Grall Date: Sun, 29 Mar 2020 19:12:34 +0000 (+0100) Subject: tools/ocaml: libxc: Check error return in stub_xc_vcpu_context_get() X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~393 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=3bf69699cacad3efb4fe6109044365f79379ed20;p=xen.git tools/ocaml: libxc: Check error return in stub_xc_vcpu_context_get() xc_vcpu_getcontext() may fail to retrieve the vcpu context. Rather than ignoring the return value, check it and throw an error if needed. Signed-off-by: Julien Grall Acked-by: Christian Lindig --- diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index 904da45c4f..0fdbeac158 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -497,6 +497,8 @@ CAMLprim value stub_xc_vcpu_context_get(value xch, value domid, vcpu_guest_context_any_t ctxt; ret = xc_vcpu_getcontext(_H(xch), _D(domid), Int_val(cpu), &ctxt); + if ( ret < 0 ) + failwith_xc(_H(xch)); context = caml_alloc_string(sizeof(ctxt)); memcpy(String_val(context), (char *) &ctxt.c, sizeof(ctxt.c));